#include "StdAfx.h"
#include "pythonscript.h"
#include "..\src\corelib\tools\qstring.h"

PythonScript::PythonScript(QObject *parent)
	: QObject(parent)
{
	valid=false;
}
PythonScript::PythonScript(QString filename)
	{
		readScript(filename);
		valid=false;
	}
bool PythonScript::readScript(QString filename)
	{
	bool result=false;
	QString FileName=filename;
	QFile fileAccess;//(FileName + ", txt");
	fileAccess.setFileName(FileName);
	QString vers;
	if(fileAccess.open(QIODevice::ReadOnly))
		{
		QTextStream reader(&fileAccess);
		QString str;
		vers=reader.atEnd();
		Py_Initialize();
		if(PyRun_SimpleString(vers.toAscii()))
			{
			valid=true;
			
			}
		Py_Finalize();
		}
	if(!result)
		{
		//QString comm = '"' + FileName + '"';
		//comm = "D:\\Python26\\python.exe " + FileName;
		QMessageBox::about(NULL, "About SIFScenarist",
			"D:\\Python26\\python.exe " + FileName);
		QProcess* proc=new QProcess(this);
		proc->start("D:\\Python26\\python.exe " + FileName);
		}
	return result;
	}
PythonScript::~PythonScript()
{

}
